package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.CustomerReturnList;
import com.atguigu.jxc.entity.query.CustomerReturnListQuery;
import com.atguigu.jxc.service.CustomerReturnListGoodsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Description: 客户退货单
 *
 * @author WJL
 * @date 2021/5/13
 */
@RestController
@RequestMapping("/customerReturnListGoods")
public class CustomerReturnListGoodsController {
    @Autowired
    CustomerReturnListGoodsService customerReturnListGoodsService;

    /**
     * 客户退货单保存
     *
     * @param returnNumber               退货单号
     * @param customerReturnList         退货单
     * @param customerReturnListGoodsStr 客户退货单商品列表（json字符串）
     * @return ServiceVO
     */
    @PostMapping("/save")
    @RequiresPermissions(value = "客户管理")// 有客户管理菜单权限的才给予调用
    public ServiceVO save(@RequestParam("returnNumber") String returnNumber, CustomerReturnList customerReturnList, String customerReturnListGoodsStr) {
        return customerReturnListGoodsService.save(returnNumber, customerReturnList, customerReturnListGoodsStr);
    }

    /**
     * 客户退货单查询（可查询条件：退货单号、客户、退款状态）
     * @param query 查询条件
     * @return 客户退货单列表
     */
    @PostMapping("/list")
    @RequiresPermissions(value = "客户管理")// 有客户管理菜单权限的才给予调用
    public Map<String,Object> list(CustomerReturnListQuery query) {
        return customerReturnListGoodsService.list(query);
    }

    /**
     * 客户退货单商品查询
     * @param customerReturnListId 客户退货单号
     * @return 客户退货单商品列表
     */
    @PostMapping("/goodsList")
    @RequiresPermissions(value = "客户管理")// 有客户管理菜单权限的才给予调用
    public Map<String,Object> queryGoodsList(Integer customerReturnListId) {
        return customerReturnListGoodsService.queryGoodsList(customerReturnListId);
    }

    /**
     * 删除客户退货单
     * @param customerReturnListId 客户退货单号
     * @return ServiceVO
     */
    @PostMapping("/delete")
    @RequiresPermissions(value = "客户管理")// 有客户管理菜单权限的才给予调用
    public ServiceVO delete(Integer customerReturnListId) {
        return customerReturnListGoodsService.delete(customerReturnListId);
    }
}
